// 语言 - system
import { DataTypes, UUIDV4 } from 'sequelize';
import { MySqlModel, getSequelize } from '../db';

/**
 * 语言
 */
class Languages extends MySqlModel {

}

Languages.init({
  id: {
    type: DataTypes.UUID, unique: 'id', allowNull: false, defaultValue: UUIDV4, validate: { isUUID: 4 }, primaryKey: true, comment: '主键', editable: false
  },
  code: {
    type: DataTypes.STRING(50), unique: 'code', allowNull: false, comment: '代码', editable: false
  },
  name: {
    type: DataTypes.STRING(200), allowNull: false, comment: '名称', logger: true
  },
  disabled: {
    type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false, comment: '禁用', logger: true
  },
  sequence: {
    type: DataTypes.INTEGER, allowNull: true, defaultValue: null, validate: { min: 0, max: 999999 }, comment: '排序', logger: true
  },
  created_id: {
    type: DataTypes.UUID, allowNull: false, validate: { isUUID: 4 }, comment: '创建用户', editable: false
  },
  updated_id: {
    type: DataTypes.UUID, allowNull: false, validate: { isUUID: 4 }, comment: '更新用户', logger: true, editable: false, model: 'Users', column: 'login_name'
  },
  created_at: {
    type: DataTypes.DATE, allowNull: false, editable: false, comment: '创建时间'
  },
  updated_at: {
    type: DataTypes.DATE, allowNull: false, editable: false, comment: '更新时间'
  },
  version: {
    type: DataTypes.INTEGER, allowNull: false, defaultValue: 0, editable: false, comment: '版本控制'
  }
}, {
  sequelize: getSequelize(),
  tableName: 'languages',
  comment: '语言'
});

export default Languages;
